package cn.iocoder.an.module.mold.dal.mysql.recheckcat2item;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.recheckcat2item.RecheckCat2itemDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.recheckcat2item.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 模具复检分类项目对照 Mapper
 *
 * @author ykk
 */
@Mapper
public interface RecheckCat2itemMapper extends BaseMapperX<RecheckCat2itemDO> {

    default PageResult<RecheckCat2itemDO> selectPage(RecheckCat2itemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RecheckCat2itemDO>()
                .eqIfPresent(RecheckCat2itemDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(RecheckCat2itemDO::getItemId, reqVO.getItemId())
                .betweenIfPresent(RecheckCat2itemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RecheckCat2itemDO::getId));
    }

    /**
     * 根据分类ID删除记录
     * @param categoryId 分类ID
     * @return 删除的记录数
     */
    @Delete("DELETE FROM mold_recheck_cat2item WHERE category_id = #{categoryId}")
    int deleteByCategoryId(@Param("categoryId") Long categoryId);

}